<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %><!-- 数据库操作需要 -->   
<%@page import="beans.*" %>
<%@page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
    <style>
        /* 样式表 */
       
        input[type="text"] {
            padding: 6px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
            width: 200px;
        }
        .button1 {
            background-color: #4CB2F6;
            color: white;
            padding: 8px 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .button1:hover {
            background-color: #0369BF;
        }
        
        .div_mation{
        	margin:auto;
			position:absolute;
			top:0;
			left:0;
			bottom:0;
			right:0;
			height:100px;
			width:300px;
			font-size:40px;
        }
        .pagination {
        	position:absolute;
        	margin:20px;
        	right:0;
        	bottom:0;
            display: inline-block;
            margin-top: 16px;
        }
        .pagination a {
            color: black;
            float: left;
            padding: 8px 16px;
            text-decoration: none;
            border: 1px solid #ddd;
            margin: 0 4px;
        }
        .pagination a.active {
            background-color: #4CB2F6;
            color: white;
        }
        .pagination a:hover:not(.active) {
            background-color: #ddd;
        }
        .btn {
        	color: #1890ff;
        	padding: 8px 16px;
        	border: none;
        	border-radius: 4px;
        	cursor: pointer;
        	text-decoration: none;
    	}
    	.btn:hover{
    		text-decoration: underline;
    	}
    	#header2 {
    	width:115%;
			height: 40px;
			background: #F6F6F6;
		}
		.tr1{
			background-color:white;
			font-size:12px;
		}
		.tr1:hover{
			background-color: RGB(160,207,255);
			
		}
		.tr1:hover td{background:none;}
		.tr2{
			background-color:RGB(249,249,249);
			font-size:12px;
		}
		.tr2:hover{
			background-color: RGB(160,207,255);
			
		}
		.tr2:hover td{background:none;}
		#div_main1{	
			width:95%;
			background:white;
			padding:10px;
		}
    </style>
</head>
<body>
	<%
	String first=(String)request.getAttribute("first");
	String EpID=request.getParameter("EpID");
	String time=request.getParameter("time");
	String ok= request.getParameter("ok");
	String addok=(String)request.getAttribute("addok");
	if(ok!=null)
	{
		if(first!=null)
		{
			EpID=(String)request.getAttribute("EpID");
			time=(String)request.getAttribute("time");
		}
			
	}
	if(EpID!=null)
	{
		EpID=EpID.replace(" ", "");
		if(EpID.equals(""))
			EpID=null;
	}
	if(time!=null)
	{
		time=time.replace(" ", "");
		if(time.equals(""))
			time=null;
	}	
	if(addok!=null)
	{
	%>
	<script type="text/javascript">
		alert("提交成功！");
	</script>
	<% }	
	
	//System.out.println("jsp:EpID:"+EpID+"time:"+time);
	if(first==null)
	{
		request.setAttribute("action", "C_Check_Search");
	%>
		<script type="text/javascript">
			var EpID = '<%= EpID %>';
	    	var time ='<%= time %>';
	    	var url = "C_Servlet?action=C_Check_Search&tt=4&EpID=" + EpID + "&time=" + time;
	    	window.location.href = url;
			/*window.location.href="C_Servlet?action=C_Check_Search&tt=1&EpID=${EpID}&time=${time}";*/
		</script>
	<% 
	}
	String ID=(String)session.getAttribute("ID");
	
	//System.out.println("#time:"+time);
	if(time!=null&&!time.equals("null"))
	{
		if(time.charAt(5)=='0')
			time=time.substring(0, 5)+time.substring(6);
		if(time.charAt(7)=='0')
			time=time.substring(0, 7)+time.substring(8);
	}
	
	//String EpID=request.getParameter("EpID");
	//String time=request.getParameter("time");
	
	//System.out.println("EpID:"+EpID+"OK:"+ok);
	

	List <CarRequestBean> list=(List<CarRequestBean>)request.getAttribute("allUsers");
	

%>	
	<div id="header2">
		<img src="img/申请用车.png" alt="Big Boat" width="30" height="30"
			style="vertical-align: middle;"> 车辆管理 > 派车单处理
	</div>
    <div>
        <form action="D-car_manage.jsp" method="post">
			<table  >
				<tr >
					<td width="300px" align="left" style="border:none;">
						<b>申请人工号</b>&nbsp;&nbsp;<input type="text"  name="EpID" >
					</td >
					<td width="600px" align="left" style="border:none">
						<b>申请日期</b>&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="date" style="height:25px;width:150px;" name="time" >
					</td>
				
					<td width="300px" align="center" style="border:none">
						<input type="hidden" name="ok" value="1">
						<input type="submit" class="button1" id="select" value="查询">
						
						<!-- <input type="reset" class="button_Select"  value="重置"> -->
					</td>
				</tr>
			</table>
			</form>
    </div>
    <div id="div_main1" style="background-color:white ;">
    <table  border="1" cellspacing = "0" style="font-size:15px;">
				<tr style="background-color:RGB(228,228,228)" >
					<td height="40px"  width="300px" align="center" style="border:none">
						<b>申请编号</b>
					</td>
					<td width="400px" align="center" style="border:none">
						<b>申请人工号</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>申请日期</b>
					</td >
					
					<td width="250px" align="center" style="border:none">
						<b>紧急程度</b>
					</td>
					
					<td width="400px" align="center" style="border:none">
						<b>用车时间</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>乘车人数</b>
					</td>
					
					<td width="500px" align="center" style="border:none">
						<b>前往地点</b>
					</td>
					<td width="200px" align="center" style="border:none">
						<b>车牌号</b>
					</td>
					<td width="300px" align="center" style="border:none">
						<b>驾驶员</b>
					</td>
					
					<td width="300px" align="center" style="border:none">
						<b>流程状态</b>
					</td>
					
					<td width="325px" align="center" style="border:none">
						<b>操作</b>
					</td>
				</tr>
			<%	int count=0,flag=0;
			if(list!=null){
				for(int i=0;i<list.size();i++)
				{ 
					String UseTime=list.get(i).getUseTime();
					UseTime=UseTime.replace("T", " ");
					String RequestID=list.get(i).getRequestID();
					String Status=list.get(i).getStatus();
					String EmpID=list.get(i).getEmpID();
					String applyTime=list.get(i).getapplyTime();
					//System.out.println("Time:"+time+"EpID"+EpID+"1");
					//System.out.println("list.get(i).getlicense_plate():"+list.get(i).getlicense_plate());
					
					if(!Status.equals("审核通过"))
							continue;
					if(EpID!=null&&time!=null&&!time.equals("null")&&!EpID.equals("null"))
					{	
						if(!EpID.equals(EmpID)||!time.equals(applyTime))
							continue;		
					}
					else if(EpID.equals("null")&&!time.equals("null"))
					{
						if(!time.equals(applyTime))
							continue;
					}
					else if(!EpID.equals("null")&&time.equals("null"))
					{
						if(!EpID.equals(EmpID))
							continue;
					}
					count++;flag=1;
					if(count%2==1)
					{
			%>
					<tr class="tr1" >
						<td height="40px"  width="300px" align="center" style="border:none">
							<%=RequestID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=EmpID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=applyTime %>
						</td >
						
						<td width="250px" align="center" style="border:none">
							<%=list.get(i).getdegree() %>
						</td>
						
						<td width="400px" align="center" style="border:none">
							<%=UseTime%>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getUsersNum() %>
						</td>
						<td width="500px" align="center" style="border:none">
							<%=list.get(i).getgoPlace() %>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getlicense_plate()%>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getDid() %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getStatus() %>
						</td>
						<td width="325px" align="center" style="border:none">
							<a class="a1" >查看</a>
							<%String checkURL="D-UseCar_CheckList.jsp?RequestID="+RequestID; %>
							<a class="a1" href=<%=checkURL %>>审核</a>
							<a class="a1" style="color:red">退回</a>
						</td>
					</tr>
					<%}else{ %>
						<tr class="tr2" >
						<td height="40px"  width="300px" align="center" style="border:none">
							<%=RequestID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=EmpID %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=applyTime %>
						</td >
						
						<td width="250px" align="center" style="border:none">
							<%=list.get(i).getdegree() %>
						</td>
						
						<td width="400px" align="center" style="border:none">
							<%=UseTime%>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getUsersNum() %>
						</td>
						<td width="500px" align="center" style="border:none">
							<%=list.get(i).getgoPlace() %>
						</td>
						<td width="200px" align="center" style="border:none">
							<%=list.get(i).getlicense_plate()%>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getDid() %>
						</td>
						<td width="300px" align="center" style="border:none">
							<%=list.get(i).getStatus() %>
						</td>
						<td width="325px" align="center" style="border:none">
							<a class="a1" >查看</a>
							<%String checkURL="D-UseCar_CheckList.jsp?RequestID="+RequestID; %>
							<a class="a1" href=<%=checkURL %>>审核</a>
							<a class="a1" style="color:red">退回</a>
						</td>
					</tr>
					<%} %>
			<%}} %>							
			</table>
			<%
				if(flag==0)
				{
			%>
				<div class="div_mation">
					暂无派送单
				</div>
			<%	}
			%>
			</div>
</body>
</html>